package com.cy.sys.service.impl;

import com.cy.commom.pojo.PageObject;
import com.cy.sys.dao.SysLogDao;
import com.cy.sys.pojo.SysLog;
import com.cy.sys.service.SysLogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {
    @Autowired
    private SysLogDao sysLogDao;
    @Override
    public PageObject<SysLog> doFindObjects(String username,Integer pageCurrent,Integer pageSize) {
        //1、校验数据
        if(pageCurrent==null || pageCurrent<0)
            throw new IllegalArgumentException("当前页码值不正确");
        //2、查询数据
        Page<SysLog> page = PageHelper.startPage(pageCurrent, pageSize);
        List<SysLog> records = sysLogDao.doFindObjects(username);
        return new PageObject<>(records,(int)page.getTotal(),pageSize,pageCurrent);
    }
}
